package org.demo;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author yexi
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Entity {

    /**
     * 主键id
     */
    private Long id;

    /**
     * 描述
     */
    private String DESCRIPTION;

    /**
     * 类型。<p>
     * 默认情况下，fastjson序列化或反序列化是根据原字段反射判断。但我们可以通过 JSONField 来自己指定该字段对应的是哪个元素
     */
    @JSONField(name = "TYPE", ordinal = 1)
    private Integer type;


    /**
     * 创建时间
     */
    @JSONField(name = "create_time", ordinal = 2)
    private Date createTime;

    public Entity(Long id, String description) {
        this.id = id;
        this.DESCRIPTION = description;
    }

    public Entity(Long id, Integer type) {
        this.id = id;
        this.type = type;
    }

    public Entity(Long id, Date createTime) {
        this.id = id;
        this.createTime = createTime;
    }

    public Entity(Long id, String description, Date createTime) {
        this.id = id;
        this.DESCRIPTION = description;
        this.createTime = createTime;
    }

    public Entity(Long id) {
        this.id = id;
    }

}
